//exsel表格上传函数
	function upload() {
       if (!empty($_FILES)) {
           $config = array(
                'exts' => array('xlsx','xls'),
                'maxSize' => 3145728,
                'rootPath' =>"./Public/",
                'savePath' => 'Uploads/',
                'subName' => array('date','Ymd'),
           );
           $upload = new \Think\Upload($config);
           //判断文件是否上传成功
            if (!$info = $upload->upload()) {
           		$this->error($upload->getError());
       		}
       		//引入第三方类库
            vendor("PHPExcel.PHPExcel");
            //获取文件上传后的地址
          $file_name=$upload->rootPath.$info['photo']['savepath'].$info['photo']['savename'];
          // dump($file_name);die;
         $extension = strtolower(pathinfo($file_name, PATHINFO_EXTENSION));
         //判断导入表格后缀格式
                if ($extension == 'xlsx') {
                    $objReader =\PHPExcel_IOFactory::createReader('Excel2007');
                    $objPHPExcel =$objReader->load($file_name, $encode = 'utf-8');
                } else if ($extension == 'xls'){
                    $objReader =\PHPExcel_IOFactory::createReader('Excel5');
                    $objPHPExcel =$objReader->load($file_name, $encode = 'utf-8');
               }
        $sheet =$objPHPExcel->getSheet(0);
        $highestRow = $sheet->getHighestRow();//取得总行数
        $highestColumn =$sheet->getHighestColumn(); //取得总列数
        //$i 表示从第几行开始读取数据 索引值从0开始
        for ($i = 2; $i <= $highestRow; $i++){
		// $data['product_id'] =$objPHPExcel->getActiveSheet()->getCell("A" . $i)->getValue();
         $data['c_name'] =$objPHPExcel->getActiveSheet()->getCell("A" .$i)->getValue();
         $data['c_ename'] =$objPHPExcel->getActiveSheet()->getCell("B" .$i)->getValue();
         $data['c_type'] = $objPHPExcel->getActiveSheet()->getCell("C". $i)->getValue();
         $data['c_style'] =$objPHPExcel->getActiveSheet()->getCell("D" .$i)->getValue();
         $data['c_price'] =$objPHPExcel->getActiveSheet()->getCell("E" . $i)->getValue();
         if($data['c_name'] === null){
         	 unlink( $file_name ); //删除上传的文件
         	$this->error('当前文档有空白处,请填写');
         }
         M('c')->add($data);
                }
                unlink( $file_name ); //删除上传的文件
                $this->success('导入成功!');
           } else {
                $this->error("请选择上传的文件");
           }
       }